"""
 encoding    : utf-8
 @File       : work_record_journal.py
 @Author     : sugar 
 @Version    :
 @Description:
 @Date       : 2024/06/15
"""
import pytest
from common.OA_tools import *


@pytest.fixture
def my_fixture():
    driver = webdriver.Firefox()
    global my_fixture2
    my_fixture2 = Oa_Page(driver)
    my_fixture2.open_llq()
    my_fixture2.login()
    yield driver
    my_fixture2.close_llq()


class Test_Journal:
    '''日志的正向测试'''
    def test01_journal_release(self,my_fixture):
        '''日志发布（账号张三）'''
        self.driver = my_fixture
        self.driver.find_element('link text', '工作记录').click()
        self.driver.find_element('link text', '我的日志').click()
        f1 = self.driver.find_element('id', 'iframe_main')
        self.driver.switch_to.frame(f1)
        self.driver.find_element('css selector', '.f-toolbar > div:nth-child(1) > button:nth-child(1)').click()
        self.driver.switch_to.default_content()
        f2 = self.driver.find_element('css selector', '.d-content > iframe:nth-child(1)')
        self.driver.switch_to.frame(f2)
        self.driver.find_element('id', 'summary').send_keys('摘要内容')
        f3 = self.driver.find_element('id', 'baidu_editor_0')
        self.driver.switch_to.frame(f3)
        self.driver.find_element('css selector', 'body').click()
        self.driver.find_element('css selector', 'body').send_keys('发布日志内容测试')
        self.driver.switch_to.parent_frame()
        self.driver.find_element('id', 'button_send').click()
        self.driver.switch_to.default_content()
        my_fixture2.work_release_right()
        my_fixture2.jietu('我的日志')

    def test02_plan_release(self,my_fixture):
        '''计划发布（账号张三）'''
        self.driver = my_fixture
        self.driver.find_element('link text', '工作记录').click()
        self.driver.find_element('link text', '我的计划').click()
        f1 = self.driver.find_element('id', 'iframe_main')
        self.driver.switch_to.frame(f1)
        self.driver.find_element('css selector', '.f-toolbar > div:nth-child(1) > button:nth-child(1)').click()
        self.driver.switch_to.default_content()
        f2 = self.driver.find_element('xpath',
                                      '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr['
                                      '2]/td/div/iframe')
        self.driver.switch_to.frame(f2)
        self.driver.find_element('xpath', '/html/body/form/div/div[1]/div[2]/input').click()
        f3 = self.driver.find_element('xpath', '/html/body/div[4]/iframe')
        self.driver.switch_to.frame(f3)
        self.driver.find_element('xpath', '/html/body/div/div[3]/table/tbody/tr[3]/td[4]').click()
        self.driver.switch_to.parent_frame()
        self.driver.find_element('xpath', '/html/body/form/div/div[1]/div[4]/input').click()
        f4 = self.driver.find_element('xpath', '/html/body/div[4]/iframe')
        self.driver.switch_to.frame(f4)
        self.driver.find_element('xpath', '/html/body/div/div[3]/table/tbody/tr[5]/td[5]').click()
        self.driver.switch_to.default_content()
        f5 = self.driver.find_element('css selector', '.d-content > iframe:nth-child(1)')
        self.driver.switch_to.frame(f5)
        self.driver.find_element('id', 'summary').send_keys('摘要内容')
        f6 = self.driver.find_element('id', 'baidu_editor_0')
        self.driver.switch_to.frame(f6)
        self.driver.find_element('css selector', 'body').click()
        self.driver.find_element('css selector', 'body').send_keys('发布计划内容测试')
        self.driver.switch_to.parent_frame()
        self.driver.find_element('id', 'button_send').click()
        self.driver.switch_to.default_content()
        my_fixture2.work_release_right()
        my_fixture2.jietu('我的计划')

    def test03_summary_release(self,my_fixture):
        '''总结发布（账号张三）'''
        self.driver = my_fixture
        self.driver.find_element('link text', '工作记录').click()
        self.driver.find_element('link text', '我的总结').click()
        f1 = self.driver.find_element('id', 'iframe_main')
        self.driver.switch_to.frame(f1)
        self.driver.find_element('css selector', '.f-toolbar > div:nth-child(1) > button:nth-child(1)').click()
        self.driver.switch_to.default_content()
        f2 = self.driver.find_element('xpath',
                                      '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr['
                                      '2]/td/div/iframe')
        self.driver.switch_to.frame(f2)
        self.driver.find_element('xpath', '/html/body/form/div/div[1]/div[2]/input').click()
        f3 = self.driver.find_element('xpath', '/html/body/div[4]/iframe')
        self.driver.switch_to.frame(f3)
        self.driver.find_element('xpath', '/html/body/div/div[3]/table/tbody/tr[3]/td[4]').click()
        self.driver.switch_to.parent_frame()
        self.driver.find_element('xpath', '/html/body/form/div/div[1]/div[4]/input').click()
        f4 = self.driver.find_element('xpath', '/html/body/div[4]/iframe')
        self.driver.switch_to.frame(f4)
        self.driver.find_element('xpath', '/html/body/div/div[3]/table/tbody/tr[5]/td[5]').click()
        self.driver.switch_to.default_content()
        f5 = self.driver.find_element('css selector', '.d-content > iframe:nth-child(1)')
        self.driver.switch_to.frame(f5)
        self.driver.find_element('id', 'summary').send_keys('摘要内容')
        f6 = self.driver.find_element('id', 'baidu_editor_0')
        self.driver.switch_to.frame(f6)
        self.driver.find_element('css selector', 'body').click()
        self.driver.find_element('css selector', 'body').send_keys('发布总结内容测试')
        self.driver.switch_to.parent_frame()
        self.driver.find_element('id', 'button_send').click()
        self.driver.switch_to.default_content()
        my_fixture2.work_release_right()
        my_fixture2.jietu('我的总结')
